package com.ljx.itbbs.server.oss.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@AllArgsConstructor
@Getter
public enum UploadTypeEnum {

    AVATAR(1, "头像", "/avatar"),
    RESOURCE(2, "资源", "/resource");

    // 上传类型
    private Integer type;
    // 描述
    private String desc;
    // 存储在minio中的路径
    private String path;

    private static Map<Integer, UploadTypeEnum> cache;

    static {
        cache = Arrays.stream(UploadTypeEnum.values()).collect(Collectors.toMap(UploadTypeEnum::getType, Function.identity()));
    }

    public static UploadTypeEnum of(Integer type) {
       return cache.get(type);
    }
}
